package com.smarthealthring.mm.presenter;

import android.util.Log;

import com.smarthealthring.mm.api.ApiRequest;
import com.smarthealthring.mm.base.BasePresenter;
import com.smarthealthring.mm.contract.LoginContract;
import com.smarthealthring.mm.contract.PersonalContract;
import com.smarthealthring.mm.utils.ErrorHanding;
import com.smarthealthring.mm.utils.ToastUtil;

import java.util.Map;

import io.reactivex.functions.Action;

/**
 * Created by bilibili on 2018/5/26.
 */

public class PersonalPresenter extends BasePresenter<PersonalContract.View> implements PersonalContract.Presenter {

    @Override
    public void updateInfo(Map<String, String> params) {
        addSubscribe(ApiRequest.updateInfo(params)
                .subscribe(response -> {
                    Log.e("更新成功===","in...");
                    mView.updateSuccess(response);
                }, throwable -> {
                    mView.updateFail();
                    ToastUtil.shortShow(ErrorHanding.handleError(throwable));
                }, new Action() {
                    @Override
                    public void run() throws Exception {
                        Log.e("更新完成===","in...");
                    }
                }));
    }
}
